import java.util.*;

public class howok {

    //数组的扩大
    /*public static int[] array2(int[] arr){
        int i=0;
        for ( i = 0; i < arr.length; i++) {
            arr[i]*=2;
        }
        return arr;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        System.out.println("没扩大前的数组"+Arrays.toString(arr));
        arr = array2(arr);
        System.out.println("扩大后的数组  "+Arrays.toString(arr));
    }*/

    //将数组的奇数向前排放，偶数向后排放
    /*public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9,10};
        int left=0;
        int right=array.length-1;
        //int i=0;
        while(left<right){
            while (array[left]%2!=0){
                left++;
            }
            while (array[right]%2==0){
                right--;
            }
            if(left<right) {
                int temp = array[left];
                array[left] = array[right];
                array[right] = temp;
            }
        }
        System.out.println(Arrays.toString(array));
    }*/

    //二分查找
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int find = scanner.nextInt();
        int[] arr={1,2,3,4,5,6,7,8,9,10};
        int left=0;
        int right=arr.length-1;

        while(left<=right){
            int mid=left+(right-left)/2;
            if(arr[mid]<find){
                left=mid+1;
            }
            else if(arr[mid]>find){
                right=mid-1;
            }
            else {
                System.out.println(mid);
                break;
            }
        }
    }*/

    //冒泡排序

   /* public static void myBubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
       int[] arr = new int[]{5, 4, 3, 2, 1};
       myBubbleSort(arr);
       System.out.println(Arrays.toString(arr));

    }*/

    //
    /*public static void main(String[] args) {
        int[] arr={1,2,3,4,5};
        int target=7;
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i+1; j <arr.length ; j++) {
                if(target==(arr[i]+arr[j])){
                    System.out.println(i+" "+j);
                }
            }
        }
    }*/

    //求数组中只出现一次的元素

    /*public static int singleNumber(int[] nums) {
        Arrays.sort(nums);
        int num=0;
        for(int x:nums){
            num ^=x;
        }
        return num;
    }

    public static void main(String[] args) {
        int[] arr1={1,2,2,3,3};
        int[] arr2={1,2,3,4,1,2,3};
        //singleNumber(arr1);
        //singleNumber(arr2);
        System.out.println(singleNumber(arr1));
        System.out.println(singleNumber(arr2));
    }*/

    //数组中的多数元素
    /*public static void main(String[] args) {
       // Scanner sc = new Scanner(System.in);
        int[] arr={1,1,1,2,2,1,2,1};
        int count=0;
        int mark=0;
        Arrays.sort(arr);
        for (int i = 0; i < arr.length-1; i++) {
            count=1;
            i=mark;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[i]==arr[j]){
                    count++;
                }
                else {
                    mark=j;
                }
            }
            if(count>(arr.length/2)){
                System.out.println(arr[i]);
            }
        }
    }*/

    //数组中是否有三个连续的奇数

    /*public static boolean threeJiShu(int[] arr) {
        if(arr.length<3){
            return false;
        }
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0 && arr[i + 1] % 2 != 0 && arr[i + 2] % 2 != 0) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,5,7,8,9,10};
        if(threeJiShu(arr)){
            System.out.println("ture");
            System.out.println("这个数组中存在连续三个奇数");
        }
        else{
            System.out.println("flase");
            System.out.println("这个数组中不存在连续三个奇数");
        }
    }*/


        /*public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            double sum = 0;
            int count = 0;
            while(true){
                double num = sc.nextInt();
                if(num == -1){
                    break;
                }
                sum = sum + num;
                count++;
            }

            if (count == 0) {
                System.out.println("无有效正数输入，无法计算平均数");
            } else {
                double average = (double) sum / count;
                System.out.println(average);
            }
            sc.close();
        }*/


/*
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int flag = 0;
        for (int i = n; i <=m ; i++) {
            flag = 0;
            for (int j = 2; j <= (int)Math.sqrt( i) ; j++) {
                if (i%j==0) {
                    flag = 1;
                    break;
                }
            }
            if (flag==0) {
                System.out.print(i+" ");
            }
        }


    }*/

    /*Stack<Integer> stack = new Stack<>();
    Queue<Integer> queue = new LinkedList<>();

    public boolean ispalindrome(int num) {
        int count = 0;
        while (num != 0) {
            queue.offer(num % 10);
            num /= 10;
            count++;
        }
        int mark = count;
        if(count%2 == 0){
            while(count>(mark/2)){
                stack.push(queue.poll());
                count--;
            }
        }else {
            while(count>(mark/2)+1){
                stack.push(queue.poll());
                count--;
            }
            queue.poll();
        }
        while(!stack.isEmpty()){
            if(stack.peek().equals(queue.peek())){
                stack.pop();
                queue.poll();
            }else {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        howok howok = new howok();
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        System.out.println(howok.ispalindrome(num));
    }*/


    // 注意类名必须为 Main, 不要有任何 package xxx 信息
/*        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            char[][] arr = new char[n*2+1][n*2+1];
            for(int i =0;i<=n*2;i++){
                for(int j = 0;j<=n*2;j++){
                    arr[i][j] = ' ';
                    if(i == j){
                        arr[i][j] = '\\';
                    }
                    if(i+j == n*2){
                        arr[i][j] = '/';
                    }
                    if(i==n && j!=n){
                        arr[i][j] = '-';
                    }
                    if(j == n && i!=n){
                        arr[i][j] = '|';
                    }
                    arr[n][n] = 'O';
                }
            }
            for(int i =0;i<=n*2;i++){
                for(int j =0;j<=n*2;j++){
                    System.out.print(arr[i][j]);
                }
                System.out.println();
            }
        */
    // 注意类名必须为 Main, 不要有任何 package xxx 信息
       /* public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int T = in.nextInt();
            int[] arr = new int[T];
            for(int i =0;i<T;i++){
                int num = in.nextInt();
                arr[i] = num;
            }
            long count = 1;
            for(int i =0;i<T;i++){
                int mark = arr[i];
                for(int j =i;j<T;j++){
                    mark = arr[i];
                    if(i == j){
                        count*=arr[i];
                    }else{
                        for(int k =i+1;k<=j;k++){
                            mark = mark^arr[k];
                        }
                        count*=mark;
                    }
                }
            }
            long ans = count%1777777777;
            System.out.print(ans);

        }*/

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n<=1) return;
        int count = 0;
        System.out.print(n+" ");
        while(true){
            if(n%2==0){
                n/=2;
                count++;
                System.out.print(n+" ");
                if(n==1){
                    break;
                }
            }
            if(n%2!=0){
                n = n*3+1;
                count++;
                System.out.print(n+" ");
                if(n==1){
                    break;
                }
            }
        }
        System.out.println();
        System.out.print("count = "+(count+1));
        Deque
    }
}
